In [1]:
%load_ext load_style
%load_style talk.css
In [2]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt # to generate plots
In [3]:
npzfile = np.load('data/ssta.nino3.30y.npz')
npzfile.files
Out[3]:
In [4]:
ssta_series = npzfile['ssta_series']
ssta_series.shape
Out[4]:
In [5]:
plt.plot(ssta_series)
Out[5]:
More info can be found from https://matplotlib.org/users/pyplot_tutorial.html
In [6]:
fig = plt.figure(figsize=(15, 6))
ax = fig.add_subplot(111)
plt.plot(ssta_series, 'g-', linewidth=2)
plt.xlabel('Years')
plt.ylabel('[$^oC$]')
plt.title('nino3 SSTA 30-year (1970-1999)', fontsize=12)
ax.set_xlim(0,361)
ax.set_ylim(-3.5,3.5)
ax.set_xticklabels(range(1970,2000,1*4))
ax.axhline(0, color='r')
plt.grid(True)
ax.autoscale_view()
plt.savefig('image/ssta_series_30y.png')
Just like the image from https://www.esrl.noaa.gov/psd/enso/mei/
In [7]:
fig = plt.figure(figsize=(15, 6))
ax = fig.add_subplot(111)
xtime = np.linspace(1,360,360)
ssta_series = ssta_series.reshape((360))
ax.plot(xtime, ssta_series, 'black', alpha=1.00, linewidth=2)
ax.fill_between(xtime, 0., ssta_series, ssta_series> 0., color='red', alpha=.75)
ax.fill_between(xtime, 0., ssta_series, ssta_series< 0., color='blue', alpha=.75)
plt.xlabel('Years')
plt.ylabel('[$^oC$]')
plt.title('nino3 SSTA 30-year (1970-1999)', fontsize=12)
ax.set_xlim(0, 361)
ax.set_ylim(-4, 4)
ax.set_xticklabels(range(1970,2000,1*4))
plt.grid(True)
ax.autoscale_view()
http://unidata.github.io/netcdf4-python/
John D. Hunter. Matplotlib: A 2D Graphics Environment, Computing in Science & Engineering, 9, 90-95 (2007), DOI:10.1109/MCSE.2007.55
Stéfan van der Walt, S. Chris Colbert and Gaël Varoquaux. The NumPy Array: A Structure for Efficient Numerical Computation, Computing in Science & Engineering, 13, 22-30 (2011), DOI:10.1109/MCSE.2011.37
Kalnay et al.,The NCEP/NCAR 40-year reanalysis project, Bull. Amer. Meteor. Soc., 77, 437-470, 1996.
In [ ]: